<script>
	export default {
		globalData: {
			APP_NAME: '无忧生活',
			APP_API_BASE_URI: 'https://wysh.ioboo.cn:44301',
			APP_LOGO: 'https://img.koalalf.com/wuyoushenghuo/logo.png'
		},
		onLaunch: function() {
			console.log('App Launch')
			// #ifdef APP-PLUS

			let pinf = plus.push.getClientInfo();

			let cid = pinf && pinf.clientid || ''; //客户端标识
			plus.push.getClientInfoAsync((info) => {
				cid = info.clientid;
				console.log('cid1', cid)
				console.log('system1', uni.getSystemInfoSync().platform)
				getui({
					client_id: cid,
					system: uni.getSystemInfoSync().platform,
				}).then(res1 => {})
			}, err => {});
			const _handlePush = function(message) {
				//跳转到某个指定的页面
				// uni.switchTab({
				// 	url: '/pages/center/index'
				// });
			};
			// plus.push.addEventListener('click', _handlePush);
			// //收到透传消息时执行的事件
			// plus.push.addEventListener('receive', _handlePush);
			plus.push.addEventListener('click', function(msg) {
				console.log('click', msg)
				let parmas = ""
				if (msg.payload.params.length > 0) {
					parmas = parseParam(obj)
				}
				if (msg.payload.page) {
					let payload = msg.payload;
					uni.navigateTo({
						url: payload.page + "?" + parmas,
					})
				}
			}, false);
			plus.push.addEventListener('receive', function(msg) {
				console.log('receive', msg)
				let parmas = ""
				if (msg.payload.params.length > 0) {
					parmas = parseParam(obj)
				}
				if (msg.payload.page) {
					let payload = msg.payload;
					uni.navigateTo({
						url: payload.page + "?" + parmas,
					})
				}

			}, false);

			//json转url参数
			var parseParam = function(param, key) {
				var paramStr = "";
				if (param instanceof String || param instanceof Number || param instanceof Boolean) {
					paramStr += "&" + key + "=" + encodeURIComponent(param);
				} else {
					$.each(param, function(i) {
						var k = key == null ? i : key + (param instanceof Array ? "[" + i + "]" : "." + i);
						paramStr += '&' + parseParam(this, k);
					});
				}
				return paramStr.substr(1);
			};
			// #endif

		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style lang="scss">
	@import "uview-ui/index.scss";
	@import "./static/iconfont.css";
	/*每个页面公共css */
	.one-line {
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
	}
	.two-line {
		overflow: hidden;
		text-overflow: ellipsis;
		display: box;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
	}
</style>
